package Configurator;

use JIP::ToolSet; # load my commonly-used modules in a single import
use parent qw( Class::Base );

use Hash::AsObject;
use Carp qw( croak );
use English qw( -no_match_vars );

sub init {
    my( $self, $config ) = @ARG;

    $self->{'fileLocation'} = $config->{'conf'}
        or croak 'required parameter "conf" not defined';

    croak('no such file') unless -f $self->{'fileLocation'};

    try {
        require $self->{'fileLocation'}
    }
    catch {
        croak "can't plug params from '". $self->{'fileLocation'} ."': ". $ARG
    };

    $self->{'settings'} = Hash::AsObject->new( $Config::params );

    return $self;
}

sub getSettings {
    my $self = shift;

    return $self->{'settings'};
}

1;
